import {ScrollView} from 'react-native-gesture-handler';
import {WhiteSpace, Button, Flex, List, Drawer, InputItem, PickerView, Modal, Provider, Toast, WingBlank} from '@ant-design/react-native';
import axios from 'axios';
import React, {Component} from 'react';
import {Image, StyleSheet, Text, View, Alert} from 'react-native';
import Albums from '~/pages/home/album/Album';
import {
    getApplyInfoByOrderId,
    getBankListByPlanItemId,
    getBankLoanByPlanItemId,
    setApplyStateByOrderId,
    updateBankFileByID,
    getBankMaterItemByBankId,
} from '~/api/bank';
import {getBankMaterialsList} from '~/api/bank';
import {UploadOwnerFile} from '~/api/owner';
import {saveBankApply} from '~/api/bank';
import {setParkingOrderPayMode, setParkingOrderState, getParkingOrderInfo} from '~/api/parking';
import Spinner from 'react-native-loading-spinner-overlay';
import {connect} from 'react-redux';

const mapGetter = (state) => {
    return {
        userinfo: state.userinfo,
        system: state.system,
    };
};
class PayLoan extends Component {
    static navigationOptions = {
        title: '0首付填资料',
    };

    constructor(props) {
        super(props);
        this.state = {
            id: this.props.navigation.getParam('params'),
            orderid: this.props.navigation.getParam('orderid'),
            orderInfo: [],
            parkingplanitemid: '',
            banklist: [],
            bankloan: [],
            monthlyinterestrate: '0.35%',
            monthlysupply: '3000',
            visible2: false,
            visible: false,
            bankName: '选择银行',
            bankId: 0,
            loanName: '选择金融产品',
            loanId: 0,
            visible3: false,
            files: [],
            username: '',
            idcard: '',
            cardID: [],
            BankFileID: [],
            shengfen: [],
            zhengxin: [],
            hukou: [],
            jiehun: [],
            fangchan: [],
            load: true,
            loanlist: [],
            bankFilelist: [],
            baseurl: '',
            spinner: false,
            a: 1,
        };
        this.getorderinfo();

        this.onChange = (value) => {
            this.setState({
                bankId: value[0],
            });
        };

        this.setBankName = () => {
            let item = this.state.banklist.find((item) => item.value === this.state.bankId);
            this.state.bankName = item.label;
            getBankLoanByPlanItemId(this.state.parkingplanitemid, this.state.bankId).then((r) => {
                if (r.code === 0) {
                    let loanlist = [];
                    r.data.forEach((item) => {
                        loanlist.push({
                            label: item.LoanName,
                            value: item.BankLoanID,
                        });
                    });
                    this.setState({
                        bankloan: loanlist,
                        loanName: loanlist[0].label,
                        loanId: loanlist[0].value,
                    });
                } else {
                    Toast.info(r.msg);
                }
            });
        };
        this.onChanges = (values) => {
            if (values != '' && values != undefined) {
                let item = this.state.bankloan.find((item) => item.value === values[0]);
                this.setState({
                    loanName: item.label,
                    loanId: values[0],
                });
            }
        };
        this.changeBankApply = () => {
            Modal.alert('提示', '当前金融信息及个人资料将被删除，确认重新选择金融信息？', [
                {
                    text: '取消',
                },
                {
                    text: '确定',
                    onPress: () => {
                        setApplyStateByOrderId({
                            id: this.state.orderid,
                            state: 4,
                        }).then((r) => {
                            if (r.code === 0) {
                                this.props.navigation.push('PayLoan', {
                                    params: this.state.id,
                                    orderid: this.state.orderid,
                                });
                                // this.props.navigation.push('MyOrderInfo', {
                                //     parkorderid: this.state.orderid,
                                // });
                            } else {
                                Toast.info(r.msg, 1);
                            }
                        });
                    },
                },
            ]);
        };
        this.changebuy = () => {
            Modal.alert('提示', '更换支付方式将删除当前金融套餐资料，确认立付尾款？', [
                {
                    text: '取消',
                },
                {
                    text: '确定',
                    onPress: () => {
                        setApplyStateByOrderId({
                            id: this.state.orderid,
                            state: 4,
                        }).then((r) => {
                            if (r.code === 0) {
                                setParkingOrderPayMode({
                                    id: this.state.orderid,
                                    state: 1,
                                }).then((r) => {
                                    if (r.code === 0) {
                                        this.props.navigation.push('PayMoney', {
                                            orderid: this.state.orderid,
                                            parkid: this.state.id,
                                        });
                                    } else {
                                        Toast.info(r.msg, 1);
                                    }
                                });
                            } else {
                                Toast.info(r.msg, 1);
                            }
                        });
                    },
                },
            ]);
        };
        //获取上传图片对应ID
        this.getBankBankId = () => {
            getBankMaterItemByBankId(this.state.bankId).then((r) => {
                if (r.code === 0) {
                    this.setState({
                        cardID: r.data,
                    });
                    console.log(this.state.cardID);
                } else {
                    Toast.info(r.msg, 1);
                }
            });
        };
        this.onClose2 = async () => {
            await this.setBankName();
            this.setState({
                visible2: false,
            });
            this.getBankBankId();
        };
        this.onClose = () => {
            this.setState({
                visible: false,
            });
        };
        this.onPress = () => {
            this.setState({
                visible3: true,
            });
        };
        //图片上传
        this.onUpload = (index, files) => {
            this.setState({
                spinner: true,
            });
            UploadOwnerFile(this.state.cardID[index].BankMaterialID, files)
                .then((r) => {
                    if (r.code === 0) {
                        for (let i = 0; i < r.data.length; i++) {
                            switch (index) {
                                case 0:
                                    let shengfenzheng = this.state.shengfen;
                                    shengfenzheng.push(r.data[i].id);
                                    this.setState({
                                        shengfen: shengfenzheng,
                                    });
                                    break;
                                case 1:
                                    let zhengxins = this.state.zhengxin;
                                    zhengxins.push(r.data[i].id);
                                    this.setState({
                                        zhengxin: zhengxins,
                                    });
                                    break;
                                case 2:
                                    let hukous = this.state.hukou;
                                    hukous.push(r.data[i].id);
                                    this.setState({
                                        hukou: hukous,
                                    });
                                    break;
                                case 3:
                                    let jiehuns = this.state.jiehun;
                                    jiehuns.push(r.data[i].id);
                                    this.setState({
                                        jiehun: jiehuns,
                                    });
                                    break;
                                case 4:
                                    let fangchans = this.state.fangchan;
                                    fangchans.push(r.data[i].id);
                                    this.setState({
                                        fangchan: fangchans,
                                    });
                                    break;
                            }
                            let BankFileIDs = this.state.BankFileID;
                            BankFileIDs.push(r.data[i].id);
                            this.setState({
                                BankFileID: BankFileIDs,
                            });
                        }
                        // if (
                        //     this.state.shengfen.length != 0 &&
                        //     this.state.zhengxin.length != 0 &&
                        //     this.state.hukou.length != 0 &&
                        //     this.state.jiehun.length != 0 &&
                        //     this.state.fangchan.length != 0
                        // ) {
                        //     this.setState({
                        //         load: false,
                        //         spinner: false,
                        //     });
                        // }
                        this.setState({
                            spinner: false,
                        });
                    } else {
                        this.setState({
                            spinner: false,
                        });
                        Alert.alert('上传失败，原因：' + r.msg);
                    }
                })
                .catch((error) => {
                    console.log(error);
                    this.setState({
                        spinner: false,
                        a: 0,
                    });
                });
        };
        //图片删除
        this.onDelete = (type, index) => {
            let del_id;
            switch (type) {
                case 0:
                    del_id = this.state.shengfen[index];
                    break;
                case 1:
                    del_id = this.state.zhengxin[index];
                    break;
                case 2:
                    del_id = this.state.hukou[index];
                    break;
                case 3:
                    del_id = this.state.jiehun[index];
                    break;
                case 4:
                    del_id = this.state.fangchan[index];
                    break;
            }
            updateBankFileByID(del_id).then((r) => {
                if (r.code === 0) {
                    switch (type) {
                        case 0:
                            this.state.shengfen.splice(index, 1);
                            break;
                        case 1:
                            this.state.zhengxin.splice(index, 1);
                            break;
                        case 2:
                            this.state.hukou.splice(index, 1);
                            break;
                        case 3:
                            this.state.jiehun.splice(index, 1);
                            break;
                        case 4:
                            this.state.fangchan.splice(index, 1);
                            break;
                    }
                } else {
                    Toast.info(r.msg, 1);
                }
            });
        };
        this.saveBankApply = () => {
            var idcard_regx = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
            if (this.state.username === '') {
                Toast.info('姓名不能为空', 1);
            } else if (this.state.idcard === '') {
                Toast.info('身份证不能为空', 1);
            } else if (this.state.bankName === '选择银行') {
                Toast.info('请选择银行', 1);
            } else if (this.state.loanName === '选择金融产品') {
                Toast.info('请选择金融产品', 1);
            } else if (this.state.cardID[0].ItemState === 1 && this.state.shengfen.length === 0) {
                Toast.info('请上传身份证图片', 1);
            } else if (this.state.cardID[1].ItemState === 1 && this.state.zhengxin.length === 0) {
                Toast.info('请上传征信证图片', 1);
            } else if (this.state.cardID[2].ItemState === 1 && this.state.hukou.length === 0) {
                Toast.info('请上传户口证图片', 1);
            } else if (this.state.cardID[3].ItemState === 1 && this.state.jiehun.length === 0) {
                Toast.info('请上传结婚证图片', 1);
            } else if (this.state.cardID[4].ItemState === 1 && this.state.fangchan.length === 0) {
                Toast.info('请上传房产证图片', 1);
            } else if (idcard_regx.test(this.state.idcard)) {
                saveBankApply({
                    BankApplyID: 0,
                    ParkingOrderID: this.state.orderid,
                    BankLoanID: this.state.loanId,
                    OwnerName: this.state.username,
                    OwnerCardID: this.state.idcard,
                    BankFileID: this.state.BankFileID,
                }).then((r) => {
                    if (r.code === 0) {
                        this.props.navigation.replace('MyOrder');
                        Toast.info('您的资料已提交，请等待银行初审', 1);
                    } else {
                        Alert.alert(r.msg);
                    }
                });
            } else {
                Toast.info('请输入正确得身份证号码', 1);
            }
        };
    }

    getorderinfo() {
        getParkingOrderInfo(this.state.orderid).then((r) => {
            if (r.code === 0) {
                this.state.parkingplanitemid = r.data.ParkingPlanItemID;
                this.getbank(r.data.ParkingPlanItemID);
                this.setState(
                    {
                        orderInfo: r.data,
                    },
                    () => {
                        this.getLoanorder();
                    },
                );
            } else {
                Alert.alert(r.msg);
            }
        });
    }
    getbank(parkingPlanItemID) {
        getBankListByPlanItemId(parkingPlanItemID).then((r) => {
            if (r.code === 0) {
                let list = [];
                r.data.forEach((item) => {
                    list.push({
                        label: item.BankName,
                        value: item.BankDataID,
                    });
                });
                this.setState({
                    banklist: list,
                });

                if (this.state.banklist.length > 0) {
                    this.state.bankId = this.state.banklist[0].value;
                    this.state.bankName = this.state.banklist[0].label;
                    this.getBankBankId();
                    getBankLoanByPlanItemId(parkingPlanItemID, this.state.banklist[0].value).then((r) => {
                        if (r.code === 0) {
                            let loanlist = [];
                            r.data.forEach((item) => {
                                loanlist.push({
                                    label: item.LoanName,
                                    value: item.BankLoanID,
                                });
                            });
                            this.setState({
                                bankloan: loanlist,
                            });
                        } else {
                            Toast.info(r.msg);
                        }
                    });
                }
            } else {
                Toast.info(r.msg);
            }
        });
    }
    getLoanorder() {
        //获取金融信息及业主上传信息
        getApplyInfoByOrderId(this.state.orderid).then((r) => {
            if (r.code === 0) {
                if (r.data != '') {
                    let item = this.state.banklist.find((item) => item.label === r.data.BankName);
                    this.setState({
                        loanlist: r.data,
                        bankFilelist: r.data.bankFile,
                        baseurl: r.data.HttpBaseUrl,
                        bankName: r.data.BankName,
                        bankId: item.value,
                        loanName: r.data.LoanName,
                        loanId: r.data.BankLoanID,
                        username: r.data.OwnerName,
                        idcard: r.data.OwnerCardID,
                    });
                }
            } else {
                console.log(r.msg);
            }
        });
    }
    setUsername = (text) => {
        this.setState({
            username: text,
        });
    };
    setIdcard = (text) => {
        this.setState({
            idcard: text,
        });
    };

    render() {
        return (
            <WingBlank size={'md'}>
                <View style={{width: '100%', height: '100%'}}>
                    <ScrollView style={{flex: 1}}>
                        <View
                            style={{
                                width: '100%',
                                height: 49,
                                alignItems: 'center',
                                flexDirection: 'row',
                                marginTop: 10,
                                backgroundColor: '#FFFFFF',
                            }}>
                            <View style={{width: '38%', alignItems: 'flex-start', paddingLeft: 8}}>
                                <Text style={styles.textsize}>
                                    <Text style={{color: 'red'}}>*</Text>请选择银行：
                                </Text>
                            </View>
                            <Flex
                                style={{width: '60%', height: 49}}
                                justify="end"
                                onPress={() => {
                                    this.state.loanlist == '' && this.setState({visible2: true});
                                    if (this.state.bankId === 0) {
                                        this.setState({
                                            bankId: this.state.banklist[0].value,
                                            bankName: this.state.banklist[0].label,
                                        });
                                    }
                                }}>
                                <Text style={{fontSize: 15}}>{this.state.bankName}</Text>
                                <Image style={{width: 6.5, height: 12, marginLeft: 15}} source={require('~/assets/info/more.png')} />
                            </Flex>
                            <Modal popup visible={this.state.visible2} animationType="slide-up" onClose={this.onClose2}>
                                <View
                                    style={{
                                        paddingVertical: 20,
                                        paddingHorizontal: 20,
                                    }}>
                                    <PickerView onChange={this.onChange} value={[this.state.bankId]} data={this.state.banklist} cols={1} />
                                </View>
                                <Flex direction={'row'} justify="between">
                                    <Button style={{width: '45%'}} type="warning" onPress={this.onClose2}>
                                        确定
                                    </Button>
                                    <Button
                                        style={{width: '45%', backgroundColor: '#F2BC38', borderColor: '#F2BC38'}}
                                        type={'primary'}
                                        onPress={this.onClose2}>
                                        取消
                                    </Button>
                                </Flex>
                            </Modal>
                        </View>
                        <View style={{width: '100%', height: 1, backgroundColor: '#EEEEEE'}} />
                        <View
                            style={{
                                width: '100%',
                                height: 49,
                                alignItems: 'center',
                                flexDirection: 'row',
                                backgroundColor: '#FFFFFF',
                            }}>
                            <View style={{width: '38%', alignItems: 'center', paddingLeft: 8}}>
                                <Text style={styles.textsize}>
                                    <Text style={{color: 'red'}}>*</Text>请选择金融产品：
                                </Text>
                            </View>
                            <Flex style={{width: '60%', height: 49}} justify="end">
                                <Text
                                    style={{fontSize: 15}}
                                    onPress={() => {
                                        this.state.loanlist == '' && this.setState({visible: true});
                                        if (this.state.loanId === 0) {
                                            if (this.state.bankloan.length > 0) {
                                                this.setState({
                                                    loanId: this.state.bankloan[0].value,
                                                    loanName: this.state.bankloan[0].label,
                                                });
                                            }
                                        }
                                    }}>
                                    {this.state.loanName}
                                </Text>
                                <Image style={{width: 6.5, height: 12, marginLeft: 15}} source={require('~/assets/info/more.png')} />
                            </Flex>
                            <Modal popup visible={this.state.visible} animationType="slide-up" onClose={this.onClose}>
                                <View
                                    style={{
                                        paddingVertical: 20,
                                        paddingHorizontal: 20,
                                    }}>
                                    <PickerView onChange={this.onChanges} value={[this.state.loanId]} data={this.state.bankloan} cols={1} />
                                </View>
                                <Button type="primary" onPress={this.onClose}>
                                    确定
                                </Button>
                            </Modal>
                        </View>
                        <View style={{width: '100%', height: 1, backgroundColor: '#EEEEEE'}} />
                        <View
                            style={{
                                width: '100%',
                                alignItems: 'center',
                                flexDirection: 'row',
                            }}>
                            <View
                                style={{
                                    width: '28%',
                                    height: 44,
                                    alignItems: 'center',
                                    backgroundColor: '#FFFFFF',
                                    flexDirection: 'row',
                                    paddingLeft: 8,
                                }}>
                                <Text style={styles.textsize}>
                                    <Text style={{color: 'red'}}>*</Text>姓名：
                                </Text>
                            </View>
                            <View width="72%">
                                <List>
                                    <InputItem
                                        editable={this.state.loanlist == '' ? true : false}
                                        onChange={this.setUsername}
                                        placeholder="请输入姓名"
                                        value={this.state.username}
                                    />
                                </List>
                            </View>
                        </View>
                        <View style={{width: '100%', height: 1, backgroundColor: '#EEEEEE'}} />
                        <View
                            style={{
                                width: '100%',
                                alignItems: 'center',
                                flexDirection: 'row',
                            }}>
                            <View
                                style={{
                                    width: '28%',
                                    height: 44,
                                    alignItems: 'center',
                                    backgroundColor: '#FFFFFF',
                                    flexDirection: 'row',
                                    paddingLeft: 7,
                                }}>
                                <Text style={styles.textsize}>
                                    <Text style={{color: 'red'}}>*</Text>身份证号：
                                </Text>
                            </View>
                            <View width="72%">
                                <List>
                                    <InputItem
                                        maxLength={18}
                                        editable={this.state.loanlist == '' ? true : false}
                                        onChange={this.setIdcard}
                                        placeholder="请输入身份证号"
                                        type={'number'}
                                        value={this.state.idcard}
                                    />
                                </List>
                            </View>
                        </View>
                        {this.state.bankFilelist != '' ? (
                            <>
                                {/* <View
                                        style={{
                                            width: '100%',
                                            flexDirection: 'column',
                                            wrap: 'wrap',
                                            backgroundColor: '#FFFFFF',
                                        }}>
                                        <View style={{ width: '100%', marginTop: 10, paddingLeft: 8 }}>
                                            <Text style={styles.textsize}>
                                                <Text style={{ color: 'red' }}>*</Text>请上传身份证(身份证正、反面)
                                        </Text>
                                        </View>
                                        <Flex wrap={'wrap'} style={{ width: '100%', marginTop: 10, marginBottom: 10 }}>
                                            <Spinner visible={this.state.spinner} textContent={'上传中...'} />
                                            <Albums
                                                onSelect={(files) => {
                                                    this.onUpload(0, files);
                                                }}
                                                onDelete={(index) => {
                                                    this.onDelete(0, index);
                                                }}
                                                id={1}
                                                spinner={this.state.a === 0 ? 0 : 1}
                                            />
                                        </Flex>
                                    </View>
                                    <View style={{width: '100%', height: 1, backgroundColor: '#EEEEEE'}}></View> */}
                                {this.state.bankFilelist.length != 0 &&
                                    this.state.bankFilelist.map((item) => {
                                        return item.MaterialName === '身份证' ? (
                                            <View
                                                style={{
                                                    width: '100%',
                                                    flexDirection: 'row',
                                                    wrap: 'wrap',
                                                    backgroundColor: '#FFFFFF',
                                                }}>
                                                <View style={{width: '35%', marginTop: 10, paddingLeft: 8}}>
                                                    <Text style={styles.textsize}>
                                                        <Text style={{color: 'red'}}>*</Text>
                                                        身份证:
                                                    </Text>
                                                </View>
                                                <Flex wrap={'wrap'} style={{width: '100%', marginTop: 10, marginBottom: 10}}>
                                                    {this.state.bankFilelist.map((item) => {
                                                        if (item.MaterialName == '身份证') {
                                                            return (
                                                                <Image
                                                                    style={{width: 100, height: 100, marginTop: 5}}
                                                                    source={{uri: this.state.baseurl + '/' + item.FileName}}
                                                                />
                                                            );
                                                        }
                                                    })}
                                                </Flex>
                                            </View>
                                        ) : null;
                                    })}
                                {this.state.bankFilelist.length != 0 &&
                                    this.state.bankFilelist.map((item) => {
                                        return item.MaterialName === '个人征信' ? (
                                            <View
                                                style={{
                                                    width: '100%',
                                                    flexDirection: 'row',
                                                    wrap: 'wrap',
                                                    backgroundColor: '#FFFFFF',
                                                }}>
                                                <View style={{width: '35%', marginTop: 10, paddingLeft: 8}}>
                                                    <Text style={styles.textsize}>
                                                        <Text style={{color: 'red'}}>*</Text>征信
                                                    </Text>
                                                </View>
                                                <Flex wrap={'wrap'} style={{width: '100%', marginTop: 10, marginBottom: 10}}>
                                                    {this.state.bankFilelist.map((item) => {
                                                        if (item.MaterialName == '个人征信') {
                                                            return (
                                                                <Image
                                                                    style={{width: 100, height: 100, marginTop: 5}}
                                                                    source={{uri: this.state.baseurl + '/' + item.FileName}}
                                                                />
                                                            );
                                                        }
                                                    })}
                                                </Flex>
                                            </View>
                                        ) : null;
                                    })}

                                {this.state.bankFilelist.length != 0 &&
                                    this.state.bankFilelist.map((item) => {
                                        return item.MaterialName === '户口本' ? (
                                            <View
                                                style={{
                                                    width: '100%',
                                                    flexDirection: 'row',
                                                    wrap: 'wrap',
                                                    backgroundColor: '#FFFFFF',
                                                }}>
                                                <View style={{width: '35%', marginTop: 10, paddingLeft: 8}}>
                                                    <Text style={styles.textsize}>
                                                        <Text style={{color: 'red'}}>*</Text>户口本
                                                    </Text>
                                                </View>
                                                <Flex wrap={'wrap'} style={{width: '100%', marginTop: 10, marginBottom: 10}}>
                                                    {this.state.bankFilelist.map((item) => {
                                                        if (item.MaterialName == '户口本') {
                                                            return (
                                                                <Image
                                                                    style={{width: 100, height: 100, marginTop: 5}}
                                                                    source={{uri: this.state.baseurl + '/' + item.FileName}}
                                                                />
                                                            );
                                                        }
                                                    })}
                                                </Flex>
                                            </View>
                                        ) : null;
                                    })}
                                {this.state.bankFilelist.length != 0 &&
                                    this.state.bankFilelist.map((item) => {
                                        return item.MaterialName === '结婚证' ? (
                                            <View
                                                style={{
                                                    width: '100%',
                                                    flexDirection: 'row',
                                                    wrap: 'wrap',
                                                    backgroundColor: '#FFFFFF',
                                                }}>
                                                <View style={{width: '35%', marginTop: 10, paddingLeft: 8}}>
                                                    <Text style={styles.textsize}>
                                                        <Text style={{color: 'red'}}>*</Text>结婚证
                                                    </Text>
                                                </View>
                                                <Flex wrap={'wrap'} style={{width: '100%', marginTop: 10, marginBottom: 10}}>
                                                    {this.state.bankFilelist.map((item) => {
                                                        if (item.MaterialName == '结婚证') {
                                                            return (
                                                                <Image
                                                                    style={{width: 100, height: 100, marginTop: 5}}
                                                                    source={{uri: this.state.baseurl + '/' + item.FileName}}
                                                                />
                                                            );
                                                        }
                                                    })}
                                                </Flex>
                                            </View>
                                        ) : null;
                                    })}
                                {this.state.bankFilelist.length != 0 &&
                                    this.state.bankFilelist.map((item) => {
                                        return item.MaterialName === '房产证' ? (
                                            <View
                                                style={{
                                                    width: '100%',
                                                    flexDirection: 'row',
                                                    wrap: 'wrap',
                                                    backgroundColor: '#FFFFFF',
                                                }}>
                                                <View style={{width: '35%', marginTop: 10, paddingLeft: 8}}>
                                                    <Text style={styles.textsize}>
                                                        <Text style={{color: 'red'}}>*</Text>房产证
                                                    </Text>
                                                </View>
                                                <Flex wrap={'wrap'} style={{width: '100%', marginTop: 10, marginBottom: 10}}>
                                                    {this.state.bankFilelist.map((item) => {
                                                        if (item.MaterialName == '房产证') {
                                                            return (
                                                                <Image
                                                                    style={{width: 100, height: 100, marginTop: 5}}
                                                                    source={{uri: this.state.baseurl + '/' + item.FileName}}
                                                                />
                                                            );
                                                        }
                                                    })}
                                                </Flex>
                                            </View>
                                        ) : null;
                                    })}
                            </>
                        ) : (
                            <>
                                <View style={{width: '100%', height: 1, backgroundColor: '#EEEEEE'}} />
                                {this.state.cardID.length != 0 && this.state.cardID[0].ItemState === 1 ? (
                                    <View
                                        style={{
                                            width: '100%',
                                            flexDirection: 'column',
                                            wrap: 'wrap',
                                            backgroundColor: '#FFFFFF',
                                        }}>
                                        <View style={{width: '100%', marginTop: 10, paddingLeft: 8}}>
                                            <Text style={styles.textsize}>
                                                <Text style={{color: 'red'}}>*</Text>请上传身份证(身份证正、反面)
                                            </Text>
                                        </View>
                                        <Flex wrap={'wrap'} style={{width: '100%', marginTop: 10, marginBottom: 10}}>
                                            <Spinner visible={this.state.spinner} textContent={'上传中...'} />
                                            <Albums
                                                onSelect={(files) => {
                                                    this.onUpload(0, files);
                                                }}
                                                onDelete={(index) => {
                                                    this.onDelete(0, index);
                                                }}
                                                id={1}
                                                spinner={this.state.a === 0 ? 0 : 1}
                                            />
                                        </Flex>
                                    </View>
                                ) : null}
                                <View style={{width: '100%', height: 1, backgroundColor: '#EEEEEE'}} />
                                {this.state.cardID.length != 0 && this.state.cardID[1].ItemState === 1 ? (
                                    <View
                                        style={{
                                            width: '100%',
                                            flexDirection: 'column',
                                            wrap: 'wrap',
                                            backgroundColor: '#FFFFFF',
                                        }}>
                                        <View style={{width: '35%', marginTop: 10, paddingLeft: 8}}>
                                            <Text style={styles.textsize}>
                                                <Text style={{color: 'red'}}>*</Text>请上传征信
                                            </Text>
                                        </View>
                                        <Flex wrap={'wrap'} style={{width: '100%', marginTop: 10, marginBottom: 10}}>
                                            <Albums
                                                onSelect={(files) => {
                                                    this.onUpload(1, files);
                                                }}
                                                onDelete={(index) => {
                                                    this.onDelete(1, index);
                                                }}
                                                id={1}
                                                spinner={this.state.a === 0 ? 0 : 1}
                                            />
                                        </Flex>
                                    </View>
                                ) : null}
                                <View style={{width: '100%', height: 1, backgroundColor: '#EEEEEE'}} />
                                {this.state.cardID.length != 0 && this.state.cardID[2].ItemState === 1 ? (
                                    <View
                                        style={{
                                            width: '100%',
                                            flexDirection: 'column',
                                            wrap: 'wrap',
                                            backgroundColor: '#FFFFFF',
                                        }}>
                                        <View style={{width: '35%', marginTop: 10}}>
                                            <Text style={styles.textsize}>
                                                <Text style={{color: 'red'}}>*</Text>请上传户口本
                                            </Text>
                                        </View>
                                        <Flex wrap={'wrap'} style={{width: '100%', marginTop: 10, marginBottom: 10}}>
                                            <Albums
                                                onSelect={(files) => {
                                                    this.onUpload(2, files);
                                                }}
                                                onDelete={(index) => {
                                                    this.onDelete(2, index);
                                                }}
                                                id={1}
                                                spinner={this.state.a === 0 ? 0 : 1}
                                            />
                                        </Flex>
                                    </View>
                                ) : null}
                                <View style={{width: '100%', height: 1, backgroundColor: '#EEEEEE'}} />
                                {this.state.cardID.length != 0 && this.state.cardID[3].ItemState === 1 ? (
                                    <View
                                        style={{
                                            width: '100%',
                                            flexDirection: 'column',
                                            wrap: 'wrap',
                                            backgroundColor: '#FFFFFF',
                                        }}>
                                        <View style={{width: '35%', marginTop: 10}}>
                                            <Text style={styles.textsize}>
                                                <Text style={{color: 'red'}}>*</Text>请上传结婚证
                                            </Text>
                                        </View>
                                        <Flex wrap={'wrap'} style={{width: '100%', marginTop: 10, marginBottom: 10}}>
                                            <Albums
                                                onSelect={(files) => {
                                                    this.onUpload(3, files);
                                                }}
                                                onDelete={(index) => {
                                                    this.onDelete(3, index);
                                                }}
                                                id={1}
                                                spinner={this.state.a === 0 ? 0 : 1}
                                            />
                                        </Flex>
                                    </View>
                                ) : null}
                                <View style={{width: '100%', height: 1, backgroundColor: '#EEEEEE'}} />
                                {this.state.cardID.length != 0 && this.state.cardID[4].ItemState === 1 ? (
                                    <View
                                        style={{
                                            width: '100%',
                                            flexDirection: 'column',
                                            wrap: 'wrap',
                                            backgroundColor: '#FFFFFF',
                                        }}>
                                        <View style={{width: '35%', marginTop: 10}}>
                                            <Text style={styles.textsize}>
                                                <Text style={{color: 'red'}}>*</Text>请上传房产证
                                            </Text>
                                        </View>
                                        <Flex wrap={'wrap'} style={{width: '100%', marginTop: 10, marginBottom: 10}}>
                                            <Albums
                                                onSelect={(files) => {
                                                    this.onUpload(4, files);
                                                }}
                                                onDelete={(index) => {
                                                    this.onDelete(4, index);
                                                }}
                                                id={1}
                                                spinner={this.state.a === 0 ? 0 : 1}
                                            />
                                        </Flex>
                                    </View>
                                ) : null}
                            </>
                        )}
                    </ScrollView>
                    {this.props.userinfo.identity === 8 && (
                        <>
                            {this.state.orderInfo.BankApplyID === 0 &&
                                this.state.orderInfo.OrderState === 1 &&
                                (this.state.orderInfo.ContractState === 6 || this.state.orderInfo.ContractState === 0) && (
                                    <Button
                                        style={{width: '100%', marginTop: 10}}
                                        type="warning"
                                        // disabled={this.state.load}
                                        onPress={() => {
                                            this.saveBankApply();
                                        }}>
                                        保存
                                    </Button>
                                )}
                            {this.state.orderInfo.BankApplyID > 0 &&
                                this.state.orderInfo.OrderState === 1 &&
                                (this.state.orderInfo.ContractState === 6 || this.state.orderInfo.ContractState === 0) && (
                                    <Flex>
                                        <Button
                                            style={{width: '30%', marginTop: 10, fontSize: 12}}
                                            type="warning"
                                            onPress={() => {
                                                this.changebuy();
                                            }}>
                                            <Text style={{color: 'white', fontSize: 10}}>不贷了，立付尾款</Text>
                                        </Button>
                                        <Button
                                            style={{width: '70%', marginTop: 10}}
                                            type="warning"
                                            onPress={() => {
                                                this.changeBankApply();
                                            }}>
                                            修改金融信息
                                        </Button>
                                    </Flex>
                                )}
                            {this.state.orderInfo.BankApplyID === 0 &&
                                this.state.orderInfo.OrderState === 1 &&
                                this.state.orderInfo.ContractState === 1 && (
                                    <Button
                                        style={{width: '100%', marginTop: 10}}
                                        type="warning"
                                        onPress={() => {
                                            this.saveBankApply();
                                        }}>
                                        重新选择金融信息
                                    </Button>
                                )}
                        </>
                    )}
                </View>
            </WingBlank>
        );
    }
}
const styles = StyleSheet.create({
    textsize: {
        fontSize: 15,
    },
    container: {
        flex: 1,
    },
    images: {
        width: 153,
        height: 97,
        marginTop: 19,
        marginLeft: 15,
    },
});
export default connect(mapGetter)(PayLoan);
